package com.midian.service.activity.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.midian.common.dao.BaseDaoTemplet;
import com.midian.common.dao.OrderHelper;
import com.midian.common.dao.SearchHelper;
import com.midian.common.dao.SearchHelper.Type;
import com.midian.common.exception.BizException;
import com.midian.common.pager.Pager;
import com.midian.model.activity.ActivityCommentPic;
import com.midian.service.common.BaseService;
import com.midian.service.activity.IActivityCommentPicService;

/**
 * 图书评论业务实现类
 * @author Mengfh
 *
 */
@Service("activityCommentPicService")
public class ActivityCommentPicServiceImpl extends BaseService implements IActivityCommentPicService {
	/**图书评论DAO*/
	private BaseDaoTemplet<ActivityCommentPic> activityCommentPicDAO;
	
	@Resource(name = "activityCommentPicDAO")
	public void setActivityCommentPicDAO(BaseDaoTemplet<ActivityCommentPic> activityCommentPicDAO) {
		this.activityCommentPicDAO = activityCommentPicDAO;
	}

	@Override
	public ActivityCommentPic add(ActivityCommentPic target) throws BizException {
		this.activityCommentPicDAO.add(target);
		return target;
	}

	@Override
	public void update(ActivityCommentPic target) throws BizException {
		this.activityCommentPicDAO.updateByConvertHql(target);
	}

	@Override
	public void delete(Serializable id) throws BizException {
		this.activityCommentPicDAO.delete(id);
	}

	@Override
	public void delete(Serializable[] ids) throws BizException {
		this.activityCommentPicDAO.delete(ids);
	}

	@Override
	public ActivityCommentPic get(Serializable id) throws BizException {
		return this.activityCommentPicDAO.get(id);
	}

	@Override
	public List<ActivityCommentPic> showList(ActivityCommentPic target, Pager pager, List<OrderHelper> helper) throws BizException {
		return this.activityCommentPicDAO.find(target, getSearchHelper(), helper, pager);
	}

	@Override
	public void opDelFlag(Serializable[] ids, Integer status) throws BizException {
		this.activityCommentPicDAO.opDelFlag(ids, status);
	}
	
	@Override
	public List getResultsBysql(String sql){
		return this.activityCommentPicDAO.executeQuerySql(sql);
	}

	@Override
	protected List<SearchHelper> getSearchHelper() {
		String[] attrs = {"activityComment","delFlag","activityComment.id","commentId"};
		Type[] types = {Type.LEFTFETCH,Type.EQ,Type.EQ,Type.EQ};
		return SearchHelper.getSearchList(attrs, types);
	}
}
